package movee.api.v1;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import movee.domain.api.SuccessResponse;
import movee.service.WebHintService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * WEB前端提示信息
 *
 * @author movee
 */
@RestController
@RequestMapping(value = "/v1/app/web/hint", produces = "application/json")
@Slf4j
@Tag(name = "WEB前端提示信息")
public class ApiWebHintControllerV1 {

    private final WebHintService hintService;

    @Autowired
    public ApiWebHintControllerV1(WebHintService hintService) {
        this.hintService = hintService;
    }

    /**
     * 解析cookie，获取用户名
     * @param cookie cookie
     * @return 用户名
     */
    @Operation(summary = "解析cookie获取用户名")
    @PostMapping(value = "/cookie/user")
    public SuccessResponse<String> getCookieUser(@RequestHeader(value = "Cookie") String cookie) {
        return new SuccessResponse<>(hintService.getCookieUser(cookie));
    }
}
